/************************************************************
*  * HONGHE CONFIDENTIAL
* __________________
* Copyright (C) 2014-2015 HONGHE Technologies. All rights reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of HONGHE Technologies.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from HONGHE Technologies.
* The author is knight(卢远强), ios software engineer.
*/

import UIKit
protocol ChannelProtocol{
    func onChnnel(channels_ur:String)
}
class ChannelController: UIViewController, UITableViewDelegate , UITableViewDataSource{
    @IBOutlet var Tv: UITableView!
   // var delegatess: onChnnel?
      var delegate: ChannelProtocol?
    var channelData:NSArray=NSArray()
    //var channelDta:HttpController=HttpController()
    override func viewDidLoad() {
        super.viewDidLoad()

    }

    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
        print(channelData.count)
     return channelData.count
    }
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
    {
        let cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "chanel")
        let rowssss:NSDictionary=channelData[indexPath.row] as! NSDictionary
        cell.textLabel?.text = rowssss["name"] as? String
        return cell
    }
    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        let rows:NSDictionary=channelData[indexPath.row] as! NSDictionary
        let channel_id:String=rows["channel_id"] as! String
        self.delegate?.onChnnel(channel_id)
        self.dismissViewControllerAnimated(true, completion: nil)
    }
    func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
        cell.layer.transform=CATransform3DMakeScale(0.1, 0.1, 1)
        UIView .animateWithDuration(0.25, animations: { () -> Void in
            cell.layer.transform=CATransform3DMakeScale(1, 1, 1)
        })
    }
}
